<template>
    <div class="reportFormPage" v-if="show">
        <div class="report-dom">
            <el-row>
                <el-col :span="5" :offset="19">
                    <div class="pageNumBox">
                        <span>第</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
                        <span>页，共</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
                        <span>页</span>
                    </div>
                </el-col>
            </el-row>
            <div class="topTwoBox">
                <div class="centerName">{{ this.form.baobmc }}</div>
                <div class="codeText">
                    <tr v-for="(item, index) in form.baobbhList">{{ item }}</tr>
                </div>
            </div>
            <div class="threeTopBox">
                <div class="left-border">
                    <div class="box-title">检测单位名称：</div>
                    <div class>{{ form.jiancdwmc }}</div>
                </div>
                <div class="right-border">
                    <span>记录编号：</span>
                    <span class="placeholder">{{ form.jilbh }}</span>
                </div>
            </div>
            <!-- .........................1111111111111111111111111111111......................................................... -->
            <div class="table-border">
                <table height="220px" class="top-table">
                    <tbody>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程名称</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcmc }}</span>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程部位/用途</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcbwyt }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center">样品信息</td>
                        <td class="specimen-border" colspan="3">
                            <span>样品名称：</span>
                            <span :class="{ 'placeholder': !form.yangpmc }">{{ form.yangpmc }}</span>
                            <span>；样品编号：</span>
                            <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                            <span>；样品数量：</span>
                            <span :class="{ 'placeholder': !form.yangpsl }">{{ form.yangpsl }}</span>
                            <span>；样品状态：</span>
                            <span :class="{ 'placeholder': !form.yangpzt }">{{ form.yangpzt }}</span>
                            <span>；来样时间：</span>
                            <span :class="{ 'placeholder': !form.yangpsj }">{{ form.yangpsj }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验检测日期</span>
                        </td>
                         <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
                        <td align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验条件</span>
                        </td>
                        <td v-if="isPdf" width="35%">
                            温度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjwd }}</span>
                            ℃；湿度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjsd }}</span>%RH
                        </td>
                        <td v-else width="35%">
                            温度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100"
                                      style="width: 15%"/>
                            ℃；湿度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100"
                                      style="width: 15%"/>
                            %RH
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">检测依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.jiancyj }}</span>
                            <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark"
                                      @dblclick.native="showBsJiancyjView" readonly/>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">判定依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.pandyj }}</span>
                            <el-input v-else type="textarea" v-model="form.pandyj" :rows="2"
                                      @dblclick.native="showBsJudgeBaseView"
                                      @focus="handleFocus('pandyj')" class="mark"/>
                        </td>
                    </tr>
                    <tr class="bottom-border">
                        <td height="50" align="center">
                            <div>主要仪器设备</div>
                            <div>名称及编号</div>
                        </td>
                        <td colspan="3">
                            <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh"
                                      class="height100 width100 mark"
                                      @dblclick.native="showBsInstrumentView" readonly></el-input>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .................................22222222222222222222222222222222............................................... -->
                <table height="616px" class="middle-table">
                    <tbody>
                    <tr trindex="0">
                        <td colspan="3" class="td3 row-td1">试验次数</td>
                        <td colspan="2" class="td2">1</td>
                        <td colspan="2" class="td2">2</td>
                        <td colspan="2" class="td2">3</td>
                        <td colspan="5" rowspan="9" class="echarts-border row-td9">
                            <table-line-log-chart :className="'echarts-border row-td9'" :chartData="chartData"
                                                  :yIsLog="true"></table-line-log-chart>
                        </td>
                    </tr>
                    <tr trindex="1">
                        <td colspan="1" rowspan="3" class="td1">
                            锥入
                            <br/>深度
                        </td>
                        <td colspan="2" class="td2 row-td1">
                            h1
                            <br/>(mm)
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h11"
                                      @change="calculatePingjh('1')"
                                      @keydown.native="handleKeyDown($event, 0, 0)"
                                      @paste.native="handlePaste($event, 0, 0)"
                                      :ref="'0_0'"/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h12"
                                      @change="calculatePingjh('2')"
                                      @keydown.native="handleKeyDown($event, 0, 1)"
                                      @paste.native="handlePaste($event, 0, 1)"
                                      :ref="'0_1'"/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h13"
                                      @change="calculatePingjh('3')"
                                      @keydown.native="handleKeyDown($event, 0, 2)"
                                      @paste.native="handlePaste($event, 0, 2)"
                                      :ref="'0_2'"/>
                        </td>
                    </tr>
                    <tr trindex="2">
                        <td colspan="2" class="td2 row-td1">
                            h2
                            <br/>(mm)
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h21"
                                      @change="calculatePingjh('1')"
                                      @keydown.native="handleKeyDown($event, 1, 0)"
                                      @paste.native="handlePaste($event, 1, 0)"
                                      :ref="'1_0'"/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h22"
                                      @change="calculatePingjh('2')"
                                      @keydown.native="handleKeyDown($event, 1, 1)"
                                      @paste.native="handlePaste($event, 1, 1)"
                                      :ref="'1_1'"/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.h23"
                                      @change="calculatePingjh('3')"
                                      @keydown.native="handleKeyDown($event, 1, 2)"
                                      @paste.native="handlePaste($event, 1, 2)"
                                      :ref="'1_2'"/>
                        </td>
                    </tr>
                    <tr trindex="3">
                        <td colspan="2" class="td2 row-td1">
                            1/2(h1+h2)
                            <br/>(mm)
                        </td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.pingjh1" disabled/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.pingjh2" disabled/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.pingjh3" disabled/>
                        </td>
                    </tr>

                    <tr trindex="4">
                        <td colspan="1" rowspan="8" class="td1">
                            <div>含</div>
                            <div>水</div>
                            <div>率</div>
                        </td>
                        <td colspan="2" class="td2 row-td1">盒号#</td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh11" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('11')" readonly/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh12" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('12')" readonly/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh21" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('21')" readonly/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh22" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('22')" readonly/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh31" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('31')" readonly/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.heh32" class="pointer mark"
                                      @dblclick.native="showBaQjDetailView('32')" readonly/>
                        </td>
                    </tr>
                    <tr trindex="5">
                        <td colspan="2" class="td2 row-td1">盒质量(g)</td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl11" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl12" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl21" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl22" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl31" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hezl32" disabled/>
                        </td>
                    </tr>
                    <tr trindex="6">
                        <td colspan="2" class="td2 row-td1">盒+湿土质量(g)</td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl11"
                                      @change="calculate('11')"
                                      @keydown.native="handleKeyDown($event, 2, 0)"
                                      @paste.native="handlePasteTwo($event, 0, 0)"
                                      :ref="'2_0'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl12"
                                      @change="calculate('12')"
                                      @keydown.native="handleKeyDown($event, 2, 1)"
                                      @paste.native="handlePasteTwo($event, 0, 1)"
                                      :ref="'2_1'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl21"
                                      @change="calculate('21')"
                                      @keydown.native="handleKeyDown($event, 2, 2)"
                                      @paste.native="handlePasteTwo($event, 0, 2)"
                                      :ref="'2_2'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl22"
                                      @change="calculate('22')"
                                      @keydown.native="handleKeyDown($event, 2, 3)"
                                      @paste.native="handlePasteTwo($event, 0, 3)"
                                      :ref="'2_3'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl31"
                                      @change="calculate('31')"
                                      @keydown.native="handleKeyDown($event, 2, 4)"
                                      @paste.native="handlePasteTwo($event, 0, 4)"
                                      :ref="'2_4'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejstzl32"
                                      @change="calculate('32')"
                                      @keydown.native="handleKeyDown($event, 2, 5)"
                                      @paste.native="handlePasteTwo($event, 0, 5)"
                                      :ref="'2_5'"/>
                        </td>
                    </tr>
                    <tr trindex="7">
                        <td colspan="2" class="td2 row-td1">盒+干土质量(g)</td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl11"
                                      @change="calculate('11')"
                                      @keydown.native="handleKeyDown($event, 3, 0)"
                                      @paste.native="handlePasteTwo($event, 1, 0)"
                                      :ref="'3_0'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl12"
                                      @change="calculate('12')"
                                      @keydown.native="handleKeyDown($event, 3, 1)"
                                      @paste.native="handlePasteTwo($event, 1, 1)"
                                      :ref="'3_1'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl21"
                                      @change="calculate('21')"
                                      @keydown.native="handleKeyDown($event, 3, 2)"
                                      @paste.native="handlePasteTwo($event, 1, 2)"
                                      :ref="'3_2'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl22"
                                      @change="calculate('22')"
                                      @keydown.native="handleKeyDown($event, 3, 3)"
                                      @paste.native="handlePasteTwo($event, 1, 3)"
                                      :ref="'3_3'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl31"
                                      @change="calculate('31')"
                                      @keydown.native="handleKeyDown($event, 3, 4)"
                                      @paste.native="handlePasteTwo($event, 1, 4)"
                                      :ref="'3_4'"/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input :type="isPdf ? 'string' : 'number'"
                                      v-model="form.hejgtzl32"
                                      @change="calculate('32')"
                                      @keydown.native="handleKeyDown($event, 3, 5)"
                                      @paste.native="handlePasteTwo($event, 1, 5)"
                                      :ref="'3_5'"/>
                        </td>
                    </tr>
                    <tr trindex="8">
                        <td colspan="2" class="td2 row-td1">水的质量(g)</td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl11" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl12" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl21" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl22" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl31" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.shuifzl32" disabled/>
                        </td>
                    </tr>
                    <tr trindex="9">
                        <td colspan="2" class="td2 row-td1">干土质量(g)</td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl11" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl12" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl21" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl22" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl31" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.gantzl32" disabled/>
                        </td>
                        <td colspan="2" class="td2">液限(%)</td>
                        <td colspan="3" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.yex" disabled/>
                        </td>
                    </tr>
                    <tr trindex="10">
                        <td colspan="2" class="td2 row-td1">含水率(%)</td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl11" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl12" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl21" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl22" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl31" disabled/>
                        </td>
                        <td colspan="1" class="td1">
                            <el-input type="text" v-model="form.hansl32" disabled/>
                        </td>
                        <td colspan="2" class="td2">塑限(%)</td>
                        <td colspan="3" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.sux" disabled/>
                        </td>
                    </tr>
                    <tr trindex="11">
                        <td colspan="2" class="td2 row-td1">平均含水率(%)</td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.hanslpjz1" disabled/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.hanslpjz2" disabled/>
                        </td>
                        <td colspan="2" class="td2">
                            <el-input type="text" v-model="form.hanslpjz3" disabled/>
                        </td>
                        <td colspan="2" class="td2">塑性指数(%)</td>
                        <td colspan="3" class="td2">
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.suxzs" disabled/>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .....................................................33333333333333333................................................... -->
                <table height="100px" class="bottom-table">
                    <tr>
                        <td>
                            <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.fujsm"
                                      @focus="handleFocus('fujsm')"/>
                        </td>
                    </tr>
                </table>
            </div>
            <!-- .................................44444444444............................................. -->
            <table height="22px" class="transparent">
                <tbody>
                <tr>
                    <td width="10%" align="right">检测：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jiancr}} -->
                    </td>
                    <td width="10%" align="right">记录：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jilr}} -->
                    </td>
                    <td width="10%" align="right">复核：</td>
                    <td align="left" width="15%">
                        <!-- {{this.form.fuhr}} -->
                    </td>
                    <td width="10%">日期：</td>
                    <td align="left" width="15%">
                        <div style="display: inline-block; margin-right: 30px;">年</div>
                        <div style="display: inline-block; margin-right: 30px;">月</div>
                        <div style="display: inline-block;">日</div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
        <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
        <ba-qj-detail-view ref="baQjDetailViewRef" :excelId="excelId" :shiyjcrq="form.shiyjcrq"
                           @select="selectBaQjDetail"></ba-qj-detail-view>
        <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    </div>
</template>

<script>
import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";
import {handleFocus, emptyConvert, handleKeyDown, handlePaste} from "@/views/reportForms/utils";
import {getKfsxzssyjlbBsInfo, getKflqhhlsybgBsInfoGetYex} from "@/api/report_jl/kf";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";
import TableLineLogChart from "@/views/reportForms/components/TableLineLogChart.vue";

export default {
    name: "kfsxzssyjlbTable",
    components: {
        BsInstrumentView,
        BsJiancyjView,
        BsJudgeBaseView,
        BaQjDetailView,
        TableLineLogChart
    },
    props: {
        excelId: {
            type: [String, Number],
            default: () => ""
        },
        syType: {
            type: [String, Number],
            default: () => ""
        },
        page: {
            type: Number,
            default: () => 0
        },
        isPdf: {
            type: Boolean,
            default: () => false
        },
        printEmpty: {
            type: Boolean,
            default: () => false
        }
    },
    data() {
        return {
            form: {
                detailList: [],
                baobbhList: []
            },
            backBgz: null,
            show: false,
            showQyxx: false,
            chartData: {
                xName: "含水率（%）",
                yName: "锥入深度（mm）",
                seriesData: [],
                time: "",
                markLineData: []
            }
        };
    },

    watch: {
        isPdf(newVal, oldVal) {
            this.form = {...emptyConvert(this.form, newVal)};
        },
        backBgz: {
            deep: true,
            immediate: true,
            handler(newVal, oldVal) {
                this.backBgzFun();
            }
        }
    },
    created() {
        this.init();
    },
    methods: {
        // 根据报表id获取当前报表信息
        init() {
            this.show = false;
            // if (!this.excelId) {
            //     const {jiancdwmc, gongcmc} = this.$store.state.dept.deptInfo;
            //     this.form.jiancdwmc = jiancdwmc;
            //     this.form.gongcmc = gongcmc;
            //     this.form.fujsm = "附加声明：";
            //     return;
            // }
            getKfsxzssyjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
                this.form = response.data;
                this.setInitialValue();
                this.show = true;
                if (!this.form.fujsm) {
                    this.form.fujsm = "附加声明：";
                }
                this.setEcharts();
                this.getYex();
            });
        },
        // 设置初始值
        setInitialValue() {
            if (this.form) {
                this.form.baobmc = this.form.baobmc || "矿粉塑性指数试验检测记录表";
                this.form.baobbh = this.form.baobbh || "JGLQ02030";
                this.$set(this.form, "baobbhList", []);
                this.form.baobbhList = ["JGLQ02030"];
            }
        },
        // 显示检测依据列表
        showBsJiancyjView() {
            this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
        },
        // 检测依据选择
        selectJiancyj(info) {
            this.form.jiancyj = info.label;
            this.form.jiancyjIds = info.ids;
            Bus.$emit("setKfBgJiancyj", {jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds});
        },
        // 显示判定依据列表
        showBsJudgeBaseView() {
            this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
        },
        // 判断依据选择
        selectJudge(info) {
            if (!this.form.pandyj) {
                this.form.pandyj = info.label;
                return;
            }
            if (info && info.label) {
                this.form.pandyj += "、" + info.label;
            }
        },
        // 显示仪器列表
        showBsInstrumentView() {
            this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
        },
        // 仪器选择
        selectInstrument(info) {
            this.form.zhuyyqsbmcjbh = info.label;
            this.form.shebIds = info.ids;
            Bus.$emit("setKfBgZhuyyqsbmcjbh", {zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds});
        },
        // 显示盒号列表
        showBaQjDetailView(type) {
            this.collectHehId();
            this.$refs.baQjDetailViewRef.init(type, this.form.hehIdList);
        },
        // 盒号选择
        selectBaQjDetail(type, obj) {
            this.form["heh" + type] = obj.hh;
            this.form["heh" + type + "Id"] = obj.detailId;
            this.form["hezl" + type] = obj.quality;
            this.calculate(type);
        },
        // 计算平均入土深度
        calculatePingjh(type) {
            if (!this.form["h1" + type] || !this.form["h2" + type]) {
                this.form["pingjh" + type] = "";
                this.getYex();
                return;
            }
            // 平均入土深度 = (h1+h2)/2
            this.form["pingjh" + type] = decimal.divide(decimal.add(this.form["h1" + type], this.form["h2" + type]), 2);
            this.setEcharts();
            this.getYex();
        },
        // 计算含水率
        calculate(type) {
            if (!this.form["hejstzl" + type] || !this.form["hejgtzl" + type]) {
                this.form["shuifzl" + type] = "";
                this.form["gantzl" + type] = "";
                this.form["hansl" + type] = "";
                this.calculateHanslpjz(type);
                return;
            }
            // 水分质量(g) = (盒+湿土质量(g)) -(盒+干土质量(g))
            this.form["shuifzl" + type] = decimal.subtract(this.form["hejstzl" + type], this.form["hejgtzl" + type]);
            if (!this.form["hezl" + type]) {
                this.form["gantzl" + type] = "";
                this.form["hansl" + type] = "";
                this.calculateHanslpjz(type);
                return;
            }
            // 干土质量（g） = (盒+干土质量(g)) -(盒质量(g))
            this.form["gantzl" + type] = decimal.subtract(this.form["hejgtzl" + type], this.form["hezl" + type]);
            // 含水率(%) = (水分质量(g)) -(干土质量（g）) * 100%
            this.form["hansl" + type] = decimal.divide(decimal.multiply(this.form["shuifzl" + type], 100), this.form["gantzl" + type], 1);
            this.calculateHanslpjz(type);
        },
        // 计算平均含水率
        calculateHanslpjz(type) {
            if (type.length < 2) {
                return;
            }
            const str = [...type][0];
            if (!this.form["hansl" + str + "1"] || !this.form["hansl" + str + "2"]) {
                this.form["hanslpjz" + str] = "";
                this.getYex();
                return;
            }
            // 含水率平均值(%) = (J+K)/2
            this.form["hanslpjz" + str] = decimal.divide(decimal.add(this.form["hansl" + str + "1"], this.form["hansl" + str + "2"]), 2, 1);
            this.setEcharts();
            this.getYex();
        },
        // 拼接图表数据
        setEcharts() {
            let seriesData = [];
            for (let index = 1; index <= 3; index++) {
                const pingjh = this.form["pingjh" + index];
                const hanslpjz = this.form["hanslpjz" + index];
                if (!pingjh || !hanslpjz) {
                    continue;
                }
                seriesData.push([Number(hanslpjz), Number(pingjh)]);
            }
            this.chartData.seriesData = seriesData;
        },
        // 获取液限值
        getYex() {
            const arr = ["pingjh1", "pingjh2", "pingjh3", "hanslpjz1", "hanslpjz2", "hanslpjz3"];
            let info = {};
            let flg = false;
            arr.forEach((item) => {
                info[item] = this.form[item];
                if (!this.form[item]) {
                    flg = true;
                }
            });
            if (flg) {
                this.form.yex = "";
                this.form.sux = "";
                this.form.suxzs = "";
                this.chartData.markLineData = [];
                this.backBgzFun();
                return;
            }
            getKflqhhlsybgBsInfoGetYex(info).then((response) => {
                const {yex, yexY, sux, suxzs} = response.data;
                this.form.yex = yex;
                this.form.sux = sux;
                this.form.suxzs = suxzs;
                const arr = [
                    [{coord: [Number(yex), 1]}, {coord: [Number(yex), Number(yexY)]}],
                    [{coord: [0, Number(yexY)]}, {coord: [Number(yex), Number(yexY)]}]
                ];
                this.chartData.markLineData = arr;
                this.backBgzFun();
                // Bus.$emit("setTgBgYex", { yex: yex, sux: sux, suxzs: suxzs });
                // Bus.$emit("setTgBgJiancjg", [
                //   { key: "3", value: yex },
                //   { key: "4", value: sux },
                //   { key: "5", value: suxzs }
                // ]);
            });
        },
        // 返回报告引入值
        backBgzFun() {
            if (this.form.yex && this.form.sux && this.form.suxzs) {
                Bus.$emit("setCjlBgJiancjg", [
                    {key: 68, value: this.form.yex}, // 液限
                    {key: 69, value: this.form.sux}, // 塑限
                    {key: 70, value: this.form.suxzs} // 塑性指数
                ]);
            }
        },
        // 汇总盒号id
        collectHehId() {
            const arr = ["11", "12", "21", "22", "31", "32"];
            let hehIdList = [];
            arr.forEach((item) => {
                if (this.form["heh" + item + "Id"]) {
                    hehIdList.push(this.form["heh" + item + "Id"]);
                }
            });
            this.form.hehIdList = hehIdList;
        },
        submitForm() {
            // this.collectHehId();
            return this.form;
        },
        handleFocus(event) {
            handleFocus(event, this.page, this.form[event]);
        },
        handleKeyDown(event, rowIndex, colIndex) {
            const maxArr = [2, 2, 5, 5]; // 每一行最多有多少可聚焦输入框（从0开始）
            const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
            if (this.$refs[ref]) {
                this.$refs[ref].focus();
            }
        },
        // 粘贴赋值方法-锥入深度
        handlePaste(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["h11", "h12", "h13"],
                ["h21", "h22", "h23"],
            ];
            const subscriptArr = [
                [0, 1, 2],
                [0, 1, 2],
            ];

            const methodsAllArr = [
                ["calculatePingjh", "calculatePingjh", "calculatePingjh"],
                ["calculatePingjh", "calculatePingjh", "calculatePingjh"],
            ];
            const parameterArr = [
                ['1', '2', '3'],
                ['1', '2', '3'],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]) {
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 粘贴赋值方法-含水率
        handlePasteTwo(event, rowIndex, colIndex) {
            const nameAllArr = [
                [
                    "hejstzl11", "hejstzl12",
                    "hejstzl21", "hejstzl22",
                    "hejstzl31", "hejstzl32",
                ],
                [
                    "hejgtzl11", "hejgtzl12",
                    "hejgtzl21", "hejgtzl22",
                    "hejgtzl31", "hejgtzl32",
                ],
            ];
            const subscriptArr = [
                [0, 1, 2, 3, 4, 5],
                [0, 1, 2, 3, 4, 5],
            ];

            const methodsAllArr = [
                [
                    "calculate", "calculate",
                    "calculate", "calculate",
                    "calculate", "calculate"
                ],
                [
                    "calculate", "calculate",
                    "calculate", "calculate",
                    "calculate", "calculate"
                ],
            ];
            const parameterArr = [
                ['11', '12', '21', '22', '31', '32'],
                ['11', '12', '21', '22', '31', '32'],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]) {
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 计算方法调用
        setCalculate(name, a, b, c, d, e) {
            this[name](a, b, c, d, e);
        }
    }
};
</script>

<style scoped>
.td1 {
    width: calc(100% / 14 * 1);
}

.td2 {
    width: calc(100% / 14 * 2);
}

.td3 {
    width: calc(100% / 14 * 3);
}

.td4 {
    width: calc(100% / 14 * 4);
}

.td5 {
    width: calc(100% / 14 * 5);
}

.td6 {
    width: calc(100% / 14 * 6);
}

.row-td1 {
    height: calc(560px / 12);
}

.row-td9 {
    height: calc(560px / 12 * 9 - 4px);
}

.echarts-border {
    width: calc((210mm - 40mm) / 14 * 5 - 4px);
    background-color: #ffffff !important;
    padding: 2px !important;
}
</style>
